rem ******MySQL backup start******
@echo off
::设置时间变量
::set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%"
::set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%"
::set "Ymd=%date:~0,4%%date:~5,2%"
::set "today=%date:~0,4%/%date:~5,2%/%date:~8,2%"

::数据库名
set "db=check"

::保存的文件名，不含后缀
set "filename=check"

::执行备份操作
::D:\phpstudy_pro\Extensions\MySQL5.7.26\bin\mysqldump --user=dev --password=dev2021 --host=192.168.7.3 --protocol=tcp --port=3306 --default-character-set=utf8 --single-transaction=TRUE --routines --events "ht_go_v2_dev" > mysql_backup_%Ymd%.sql
D:\phpstudy_pro\Extensions\MySQL5.7.26\bin\mysqldump --user=root --password=root --host=127.0.0.1 --protocol=tcp --port=3306 --default-character-set=utf8 --single-transaction=TRUE --routines --events %db% > %filename%.sql

::删除一周前的备份数据
::forfiles /p "D:\WWW\mysql_backup" /s /m mysql_backup_*.sql /d -7 /c "cmd /c del @path"
::forfiles /s /m mysql_backup_*.sql /d -1 /c "cmd /c del @path"

:: pause
@echo on
rem ******MySQL backup end******